#ifndef CListBoxH
#define CListBoxH

#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <StdCtrls.hpp>
#include "CtrlStd.h"
#include "Messages.h"

#define COL_EDIT_LISTBOX            clWindow

#define ECART_LIBEL_LISTBOX         10
#define TOP_LIBELLE_LISTBOX          3

class PACKAGE_CTRLSTD CListBox : public TCustomListBox
	{
	private:
		typedef                   TCustomListBox inherited;
		bool                      FReadOnly;
		bool		                  FIsEcranChaine;
		AnsiString                FLibelle;
		TFont                    *FLibelleFont;
		int                       FSizeEsp;   // Taille entre le libelle et l'edit
    TLabel                   *LLibelle;
    int                       iLastSelect;
    bool                      FObligatoire;
    TCorrectementRempliEvent  FpfnOnEstCorrectementRempli;
    TWndMethod                OldWndProc_Parent;
    TWinControl               *FOldParent;
    bool                      FBleuSiHint;

	__published:
		__property              Anchors;
		__property              Align;
		__property              Color;
		__property              Columns;
		__property				      DragCursor;
		__property				      DragMode;
		__property              ExtendedSelect;
    __property bool         Enabled         = { read=GetEnabled,    write=SetEnabled,    default = true  };
    __property              Font;
    __property              HelpContext;
    __property              Hint;
		__property              IntegralHeight;
		__property bool         IsEcranChaine   = { read=FIsEcranChaine,write=FIsEcranChaine,default = true  };
		__property              ItemHeight;
		__property              ItemIndex;
		__property              Items;
    __property AnsiString   Libelle         = { read=FLibelle,      write=SetLibelle                     };
    __property TFont        *LibelleFont    = { read=GetLibelleFont,write=SetLibelleFont                 };
		__property              MultiSelect;
    __property              ParentColor;
    __property              ParentFont;
    __property              ParentShowHint;
    __property              PopupMenu;
    __property bool         ReadOnly        = { read=FReadOnly,     write=SetReadOnly,   default = false };
    __property              ShowHint;
		__property              Sorted;
		__property              Style;
    __property              TabOrder;
    __property              TabStop;
		__property              TabWidth;
    __property              TopIndex;
    __property              Visible;
    __property bool         Obligatoire     = { read=FObligatoire,  write=SetObligatoire,default = false };
    __property bool         BleuSiHint     = { read=FBleuSiHint,  write=SetBleuSiHint,default = false };
    // Evenements
    __property OnDrawItem;
    __property OnStartDrag;
    __property OnDragDrop;
    __property OnDragOver;
    __property OnEndDrag;
    __property OnKeyDown;
    __property OnKeyPress;
    __property OnKeyUp;
    __property OnEnter;
    __property OnExit;
    __property OnMeasureItem;
    __property OnMouseDown;
    __property OnMouseMove;
    __property OnMouseUp;
    __property OnClick;
    __property OnDblClick;
    __property TCorrectementRempliEvent OnEstCorrectementRempli = { read=FpfnOnEstCorrectementRempli, write=FpfnOnEstCorrectementRempli};

  private:
        void            __fastcall SetEnabled(      bool        bVisible        );
        void            __fastcall SetLibelle( const AnsiString aLibelle        );
        void            __fastcall SetLibelleFont(  TFont       *FFont          );
        void            __fastcall SetReadOnly(     bool        bReadOnly       );
        void            __fastcall SetSizeEsp(      int         iSizeEsp        );
        bool            __fastcall GetEnabled();
        TFont *         __fastcall GetLibelleFont() const;
        void            __fastcall SetObligatoire( bool bObligatoire);
        void            __fastcall WndProc_Parent( TMessage &Message );
        void            __fastcall SetBleuSiHint( bool bBleuSiHint);

	protected:
	    	DYNAMIC void  	__fastcall KeyDown( Word &Key, Classes::TShiftState Shift);
        virtual void    __fastcall WndProc(             TMessage    &Message );
        DYNAMIC void    __fastcall KeyPress(            char        &Key );
        void            __fastcall LibelleFontChange(   TObject     *Sender );
        virtual void    __fastcall SetParent(TWinControl* AParent);

    public:
        __fastcall CListBox(TComponent* Owner);
        virtual __fastcall ~CListBox();
        bool __fastcall EstCorrectementRempliDefault( void);
    };
#endif
